Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI subsystem additions #16330

Closed
wants to merge 4 commits into from
Closed

UI subsystem additions #16330

wants to merge 4 commits into from

Conversation

LinYunMo
Copy link
Contributor

@LinYunMo LinYunMo commented Sep 25, 2023

Re:#15693
Re:https://github.com/cocos/3d-tasks/issues/17388
Re: #15890
depend:#16292

Need change after #16292 merged

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@LinYunMo LinYunMo requested a review from SantyWang September 25, 2023 09:22
@github-actions
Copy link

github-actions bot commented Sep 25, 2023

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -3313,8 +3313,9 @@
         protected _textStyle: __private._cocos_2d_assembler_label_text_style__TextStyle | null;
         protected _textLayout: __private._cocos_2d_assembler_label_text_layout__TextLayout | null;
         protected _textRenderData: __private._cocos_2d_assembler_label_text_output_data__TextOutputRenderData | null;
         protected _textLayoutData: __private._cocos_2d_assembler_label_text_output_data__TextOutputLayoutData | null;
+        protected _layoutDirty: boolean;
         constructor();
         onEnable(): void;
         onDestroy(): void;
         /**
@@ -3332,8 +3333,9 @@
         protected _canRender(): boolean;
         protected _flushAssembler(): void;
         protected _applyFontTexture(): void;
         protected changeMaterialForDefine(): void;
+        protected _nodeStateChange(transformType: TransformBit): void;
     }
     /**
      * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
      */
@@ -3373,10 +3375,8 @@
         protected _drawInfoType: __private._cocos_2d_renderer_render_draw_info__RenderDrawInfoType;
         protected _multiOwner: boolean;
         get multiOwner(): boolean;
         set multiOwner(val: boolean);
-        protected _batcher: UI | null;
-        get batcher(): UI;
         constructor(vertexFormat?: gfx.Attribute[]);
         isValid(): false | __private._cocos_2d_renderer_static_vb_accessor__StaticVBAccessor;
         initRenderDrawInfo(comp: UIRenderer, drawInfoType?: __private._cocos_2d_renderer_render_draw_info__RenderDrawInfoType): void;
         removeRenderDrawInfo(comp: UIRenderer): void;
@@ -3574,11 +3574,10 @@
      * @en UI rendering process
      * @zh UI 渲染流程
      */
     export class UI implements __private._cocos_2d_renderer_i_batcher__IBatcher {
-        protected _nativeObj: __private._cocos_2d_renderer_native_2d__NativeBatcher2d;
-        get nativeObj(): __private._cocos_2d_renderer_native_2d__NativeBatcher2d;
-        get currBufferAccessor(): __private._cocos_2d_renderer_static_vb_accessor__StaticVBAccessor;
+        static getInstance(): UI;
+        static getFirstRenderCamera(node: Node): renderer.scene.Camera | null;
         get batches(): memop.CachedArray<__private._cocos_2d_renderer_draw_batch__DrawBatch2D>;
         device: gfx.Device;
         constructor(_root: Root);
         initialize(): boolean;
@@ -3592,29 +3591,22 @@
          *
          * @param comp @en The render root of 2d.
          *             @zh 2d 渲染入口组件。
          */
-        addScreen(comp: RenderRoot2D): void;
+        addScreen(node: Node): void;
         /**
          * @zh
          * Removes the Canvas from the list.
          *
          * @param comp @en The target to removed.
          *             @zh 被移除的屏幕。
          */
-        removeScreen(comp: RenderRoot2D): void;
+        removeScreen(node: Node): void;
         sortScreens(): void;
-        getFirstRenderCamera(node: Node): renderer.scene.Camera | null;
         update(): void;
         uploadBuffers(): void;
         reset(): void;
-        /**
-         * @zh 如果有必要,为相应的顶点布局切换网格缓冲区。
-         * @en Switch the mesh buffer for corresponding vertex layout if necessary.
-         * @param attributes use VertexFormat.vfmtPosUvColor by default
-         */
-        switchBufferAccessor(attributes?: gfx.Attribute[]): __private._cocos_2d_renderer_static_vb_accessor__StaticVBAccessor;
-        registerBufferAccessor(key: number, accessor: __private._cocos_2d_renderer_static_vb_accessor__StaticVBAccessor): void;
+        syncMeshBuffersToNative(accId: number, buffers: __private._cocos_2d_renderer_native_2d__NativeUIMeshBuffer[]): void;
         updateBuffer(attributes: gfx.Attribute[], bid: number): void;
         /**
          * @en
          * Render component data submission process of UI.
@@ -3713,9 +3705,9 @@
          * 强制刷新材质。
          */
         flushMaterial(mat: Material): void;
         walk(node: Node, level?: number): void;
-        syncMeshBuffersToNative(accId: number, buffers: MeshBuffer[]): void;
+        releaseDescriptorSetCache(texture: __private._cocos_asset_assets_texture_base__TextureBase): void;
     }
     /**
      * @deprecated since v3.6.0, this is an engine private interface that will be removed in the future.
      * @internal
@@ -7766,8 +7758,9 @@
         get pipelineEvent(): __private._cocos_rendering_pipeline_event__IPipelineEvent;
         /**
          * @en The draw batch manager for 2D UI, for engine internal usage, user do not need to use this.
          * @zh 2D UI 渲染合批管理器,引擎内部使用,用户无需使用此接口
+         * @deprecated Since v3.9.0, this is an engine private interface that will be removed in the future.
          */
         get batcher2D(): UI;
         /**
          * @en Render scenes list
@@ -27322,8 +27315,14 @@
          * @zh 一帧结束之后所触发的事件。
          * @event Director.EVENT_END_FRAME
          */
         static readonly EVENT_END_FRAME = "director_end_frame";
+        /**
+         * @en The event which will be triggered at the time that UI system update.
+         * @zh UI系统开始更新时的事件。
+         * @event Director.EVENT_UPDATE_UI
+         */
+        static readonly EVENT_UPDATE_UI = "director_update_ui";
         static instance: Director;
         /**
          * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
          */
@@ -59544,55 +59543,8 @@
             nuv: number[];
             minPos: math.Vec3;
             maxPos: math.Vec3;
         }
-        /**
-         * @internal
-         */
-        export class _cocos_2d_renderer_static_vb_accessor__StaticVBChunk {
-            vertexAccessor: _cocos_2d_renderer_static_vb_accessor__StaticVBAccessor;
-            bufferId: number;
-            meshBuffer: MeshBuffer;
-            vertexOffset: number;
-            vb: Float32Array;
-            indexCount: number;
-            get ib(): Readonly<Uint16Array>;
-            constructor(vertexAccessor: _cocos_2d_renderer_static_vb_accessor__StaticVBAccessor, bufferId: number, meshBuffer: MeshBuffer, vertexOffset: number, vb: Float32Array, indexCount: number);
-            setIndexBuffer(indices: ArrayLike<number>): void;
-        }
-        export class _cocos_2d_renderer_buffer_accessor__BufferAccessor {
-            get attributes(): Readonly<gfx.Attribute[]>;
-            get vertexFormatBytes(): number;
-            get floatsPerVertex(): number;
-            protected _device: gfx.Device;
-            protected _attributes: gfx.Attribute[];
-            protected _vertexFormatBytes: number;
-            protected _floatsPerVertex: number;
-            protected _buffers: MeshBuffer[];
-            constructor(device: gfx.Device, attributes: gfx.Attribute[]);
-            initialize(): void;
-            reset(): void;
-            request(vertexCount?: number, indexCount?: number): void;
-            appendBuffers(vertices: Float32Array, indices: Uint16Array): void;
-            uploadBuffers(): void;
-            destroy(): void;
-        }
-        export class _cocos_2d_renderer_static_vb_accessor__StaticVBAccessor extends _cocos_2d_renderer_buffer_accessor__BufferAccessor {
-            static IB_SCALE: number;
-            static ID_COUNT: number;
-            get id(): number;
-            constructor(device: gfx.Device, attributes: gfx.Attribute[], vCount?: number, iCount?: number);
-            destroy(): void;
-            reset(): void;
-            getVertexBuffer(bid: number): Float32Array;
-            getIndexBuffer(bid: number): Uint16Array;
-            getMeshBuffer(bid: number): MeshBuffer;
-            uploadBuffers(): void;
-            appendIndices(bufferId: number, indices: Uint16Array): void;
-            allocateChunk(vertexCount: number, indexCount: number): _cocos_2d_renderer_static_vb_accessor__StaticVBChunk | null;
-            recycleChunk(chunk: _cocos_2d_renderer_static_vb_accessor__StaticVBChunk): void;
-            static generateID(): number;
-        }
         export class _cocos_2d_renderer_draw_batch__DrawBatch2D {
             get inputAssembler(): gfx.InputAssembler | null;
             set inputAssembler(ia: gfx.InputAssembler | null);
             get descriptorSet(): gfx.DescriptorSet | null;
@@ -59611,21 +59563,18 @@
             clear(): void;
             fillPasses(mat: Material | null, dss: any, dssHash: any, patches: any): void;
         }
         export interface _cocos_2d_renderer_i_batcher__IBatcher {
-            currBufferAccessor: _cocos_2d_renderer_static_vb_accessor__StaticVBAccessor;
             readonly batches: memop.CachedArray<_cocos_2d_renderer_draw_batch__DrawBatch2D>;
             device: gfx.Device;
             initialize(): boolean;
             destroy(): any;
-            addScreen(comp: RenderRoot2D): any;
-            getFirstRenderCamera(node: Node): renderer.scene.Camera | null;
-            removeScreen(comp: RenderRoot2D): any;
+            addScreen(node: Node): any;
+            removeScreen(node: Node): any;
             sortScreens(): any;
             update(): any;
             uploadBuffers(): any;
             reset(): any;
-            switchBufferAccessor(attributes?: gfx.Attribute[]): _cocos_2d_renderer_static_vb_accessor__StaticVBAccessor;
             commitComp(comp: UIRenderer, renderData: BaseRenderData | null, frame: _cocos_asset_assets_texture_base__TextureBase | SpriteFrame | null, assembler: any, transform: Node | null): any;
             commitModel(comp: UIMeshRenderer | UIRenderer, model: renderer.scene.Model | null, mat: Material | null): any;
             autoMergeBatches(renderComp?: UIRenderer): any;
             forceMergeBatches(material: Material, frame: _cocos_asset_assets_texture_base__TextureBase | SpriteFrame | null, renderComp: UIRenderer): any;
@@ -60155,16 +60104,55 @@
             contentSizeExtend: math.Size;
             startPosition: math.Vec2;
             reset(): void;
         }
-        export class _cocos_2d_renderer_native_2d__NativeBatcher2d {
-            syncMeshBuffersToNative(accId: number, buffers: _cocos_2d_renderer_native_2d__NativeUIMeshBuffer[]): any;
-            update(): any;
-            uploadBuffers(): any;
-            reset(): any;
-            syncRootNodesToNative(nodes: Node[]): any;
-            releaseDescriptorSetCache(texture: gfx.Texture, sampler: gfx.Sampler): any;
+        export class _cocos_2d_renderer_buffer_accessor__BufferAccessor {
+            get attributes(): Readonly<gfx.Attribute[]>;
+            get vertexFormatBytes(): number;
+            get floatsPerVertex(): number;
+            protected _device: gfx.Device;
+            protected _attributes: gfx.Attribute[];
+            protected _vertexFormatBytes: number;
+            protected _floatsPerVertex: number;
+            protected _buffers: MeshBuffer[];
+            constructor(device: gfx.Device, attributes: gfx.Attribute[]);
+            initialize(): void;
+            reset(): void;
+            request(vertexCount?: number, indexCount?: number): void;
+            appendBuffers(vertices: Float32Array, indices: Uint16Array): void;
+            uploadBuffers(): void;
+            destroy(): void;
         }
+        export class _cocos_2d_renderer_static_vb_accessor__StaticVBAccessor extends _cocos_2d_renderer_buffer_accessor__BufferAccessor {
+            static IB_SCALE: number;
+            static ID_COUNT: number;
+            get id(): number;
+            constructor(device: gfx.Device, attributes: gfx.Attribute[], vCount?: number, iCount?: number);
+            destroy(): void;
+            reset(): void;
+            getVertexBuffer(bid: number): Float32Array;
+            getIndexBuffer(bid: number): Uint16Array;
+            getMeshBuffer(bid: number): MeshBuffer;
+            uploadBuffers(): void;
+            appendIndices(bufferId: number, indices: Uint16Array): void;
+            allocateChunk(vertexCount: number, indexCount: number): _cocos_2d_renderer_static_vb_accessor__StaticVBChunk | null;
+            recycleChunk(chunk: _cocos_2d_renderer_static_vb_accessor__StaticVBChunk): void;
+            static generateID(): number;
+        }
+        /**
+         * @internal
+         */
+        export class _cocos_2d_renderer_static_vb_accessor__StaticVBChunk {
+            vertexAccessor: _cocos_2d_renderer_static_vb_accessor__StaticVBAccessor;
+            bufferId: number;
+            meshBuffer: MeshBuffer;
+            vertexOffset: number;
+            vb: Float32Array;
+            indexCount: number;
+            get ib(): Readonly<Uint16Array>;
+            constructor(vertexAccessor: _cocos_2d_renderer_static_vb_accessor__StaticVBAccessor, bufferId: number, meshBuffer: MeshBuffer, vertexOffset: number, vb: Float32Array, indexCount: number);
+            setIndexBuffer(indices: ArrayLike<number>): void;
+        }
         export class _cocos_2d_utils_dynamic_atlas_atlas__DynamicAtlasTexture extends Texture2D {
             /**
              * @en
              * Initialize the render texture.

@minggo minggo requested review from qiuguohua and removed request for SantyWang December 19, 2023 03:34
@minggo minggo closed this Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants